package com.fzh.wangxiao.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

/**
 * 随机数工具类
 * @author fzg
 *
 */
public class UUIDUtils {

    /**
     * 生成商品编号 16位
     * @return
     */
    public synchronized static String getNum16() {
        String rabdomStr = String.valueOf((Math.random() * 9 + 1) * 100000);
        LocalDateTime ldt = LocalDateTime.now();
        String dataStr =  ldt.format(DateTimeFormatter.ofPattern("yMMdHHmmss"));
        String numStr = rabdomStr.substring(0, 6);
        numStr = dataStr + numStr;
        return numStr;
    }

    public synchronized static Long getRandomNumber(Integer len) {
        Random random = new Random();
         int s = random.nextInt(len - 1 + 1) + 0;
        return Long.parseLong(s+"");
    }



}
